package edpool;


public class ProducerPackage<T> extends ExchangerPackage<T>
{
	private ExchangerState<T> waitingStateObject;
	private ExchangerState<T> eliminatingStateObject;

	public ProducerPackage(GlobalExchangeStates<T> globalExchangeStates)
	{
		super(PackageTypeEnum.Producer, globalExchangeStates);

	}
	
	public void initialize(T value)
	{
		super.initialize();
		this.value = value;
	}
	
	public void clear()
	{
		value = null;
		waitingStateObject = null;
		eliminatingStateObject = null;
	}
	  	
	public  ExchangerState<T> getWaitingStateObject()
	{
		if (waitingStateObject == null)
			waitingStateObject = new ExchangerState<T>(ExchangerStateEnum.Waiting, value, PackageTypeEnum.Producer);
		return waitingStateObject;
	}
		  
	public ExchangerState<T> getEliminatingStateObject()
	{
		if (eliminatingStateObject == null)
			eliminatingStateObject = new ExchangerState<T>(ExchangerStateEnum.Elimination, value, PackageTypeEnum.Producer);
		return eliminatingStateObject;
	}

	public ExchangerState<T> getDiffractingStateObject()
	{
		return globalExchangeStates.ProducerDiffracted;
	}

}
